package com.demo.logistics.stockControl.ui;

import java.util.ArrayList;
import java.util.List;

import com.demo.logistics.R;
import com.demo.logistics.entities.Products;
import com.demo.logistics.entities.Stocks;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class StockListArrayAdapter extends ArrayAdapter<Stocks> {

	private Activity context;
	private ArrayList<Stocks> stocksObjList;
	
	public StockListArrayAdapter(Activity context,
			ArrayList<Stocks> objects) {
		super(context, R.layout.stocklist_rowlayout, objects);
		this.context = context;
		this.stocksObjList = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		LayoutInflater inf = context.getLayoutInflater();
		View rowView = inf.inflate(R.layout.stocklist_rowlayout, null, true);
		TextView tvId = (TextView)rowView.findViewById(R.id.tv_stock_id);
		TextView tvProdName = (TextView)rowView.findViewById(R.id.tv_prod);
		TextView tvQty = (TextView)rowView.findViewById(R.id.tv_qty);
		TextView tvLorryNo = (TextView)rowView.findViewById(R.id.tv_lorry_no);
		TextView tvDriverName = (TextView)rowView.findViewById(R.id.tv_driver_name);
		Stocks tempStock = stocksObjList.get(position);
		tvId.setText(((Integer)tempStock.getId()).toString());
		tvProdName.setText(tempStock.getProductName());
		tvQty.setText(((Integer)tempStock.getQuantity()).toString());
		tvLorryNo.setText(tempStock.getLorryPlateNo());
		tvDriverName.setText(tempStock.getDriverName());
		return rowView;
	}
	
	

}
